1 #include<iostream>
2 #include<conio.h>
3 #include<string.h>
4 #include<stdlib.h>
5 using namespace std;
6
7 struct patient
8 {
9 long long ID;
10 string firstname;
11 string lastname;
12 int age;
13 char blood[5];
14 char gender;
15 patient*next;
16 };
17 class linkedqueue
18 {
19 patient *head,*last;
20 public:
21 linkedqueue() //constructor
22 {
23 head=NULL;
24 last=NULL;
25 }
26 patient input();
27 void insertatend();
28 void insertatbeg();
29 void getpatientout();
30 void listofpatients();
31 int search(int);
32 char departmentname[50];
33 };
34
35 int linkedqueue :: search(int item)
36 {
37 if(head==NULL)
38 return false;
39 else
40 {
41 int flag=0;
42 patient*p=new patient();
43 p=head;
44
45 while( p->next!=NULL && p->ID!=item )
46 {
47 p=p->next;
48 }
49 if(p->ID==item)
50 {
51 flag=1;
52 return true;
53 }
54 if(flag==0)
55 return false;
56 }
57 }
58
59 int readnumber()
60 {
61 char b[20];
62 cin.getline(b, sizeof(b));
63 return atoi(b);
64 }
65
66 patient linkedqueue :: input() //taking input of the patient1353
67 {
68 int flag=0;
69 patient *p=new patient();
70 cout << "\n\tPlease enter data for patient\n";
71 cout<<"\n\tFirst name : ";
72 getline(cin,p->firstname);
73 cout << "\tLast name : ";
74 getline(cin,p->lastname);
75 again :
76 cout << "\tBlood Group : ";
77 cin>>p->blood;
78 if((strcmp(p->blood,"A+")==0)||(strcmp(p->blood,"a+")==0)||(strcmp(p->blood,"A-")==0)||(strcmp(p->blood,"a-")==0)||
79 (strcmp(p->blood,"B+")==0)||(strcmp(p->blood,"b+")==0)||(strcmp(p->blood,"B-")==0)||(strcmp(p->blood,"b-")==0)||
80 (strcmp(p->blood,"O+")==0)||(strcmp(p->blood,"o+")==0)||(strcmp(p->blood,"O-")==0)||(strcmp(p->blood,"o-")==0)||
81 (strcmp(p->blood,"AB+")==0)||(strcmp(p->blood,"ab+")==0)||(strcmp(p->blood,"AB-")==0)||(strcmp(p->blood,"ab-")==0))
82 flag=1;
83 if(flag==0)
84 {
85 cout<<"\nWrong Entry...Enter a valid Blood Group..Try Again..";
86 goto again;
87
88 }
89 cout<<"\tGender : (m/f)";
90 cin>>p->gender;
91 cout<<"\tAge : ";
92 cin>>p->age;
93 cout<<"\tMobile number : ";
94 cin>>p->ID;//=readnumber()1353;
95
96
97 if(search(p->ID))
98 {
99 p->ID=0;
100 cout << "\n\tData not valid. Operation cancelled.";
101 }
102 return *p;
103 }
104
105 void output(patient *p)
106 {
107 cout<<"\n**********************************";
108 cout<<"\n\nPatient data:";
109 cout<<"\n\nFirst Name : "<<p->firstname;
110 cout<<"\nLast Name : "<<p->lastname;
111 cout<<"\nGender : "<<p->gender;
112 cout<<"\nAge : "<<p->age;
113 cout<<"\nBlood Group : "<<p->blood;
114 cout<<"\nMobile Number : "<<p->ID;
115 cout<<"\n\n**********************************";
116 }
117 void linkedqueue :: insertatbeg()
118 {
119 patient*p=new patient();
120 *p=input();
121 if(p->ID==0)
122 return;
123
124 if(head==NULL)
125
126 {
127 head=p;
128 last=p;
129 p->next=NULL;
130 }
131 else
132 {
133 p->next=head;
134 head=p;
135 }
136 system("cls");
137 cout << "\n\tPatient added:";
138 output(p);
139 }
140 void linkedqueue:: insertatend()
141 {
142 patient*p=new patient();
143 *p=input();
144 if(p->ID==0)
145 return;
146
147 if(head==NULL)
148 {
149 head=p;
150 last=p;
151 p->next=NULL;
152 }
153 else
154 {
155 p->next=NULL;
156 last->next=p;
157 last=p;
158 }
159 system("cls");
160 cout << "\n\tPatient added:";
161 output(p);
162 }
163 void linkedqueue :: getpatientout()
164 {
165 system("cls");
166 if(head==NULL)
167 {
168 cout<<"\n\tNo Patient to operate";
169 }
170 else
171 {
172 patient*p=new patient();
173 p=head;
174 head=head->next;
175 cout << "\n\tPatient to operate:";
176 output(p);
177 }
178 }
179
180 void linkedqueue :: listofpatients()
181 {
182 if(head==NULL)
183 {
184 cout<<"\n\tNo patient";
185 }
186 patient*p=new patient;
187 p=head;
188 while(p!=NULL)
189 {
190 cout<<"\nPatient data:";
191 cout<<"\nFirst Name : "<<p->firstname;
192 cout<<"\nLast Name : "<<p->lastname;
193 cout<<"\nGender : "<<p->gender;
194 cout<<"\nAge : "<<p->age;
195 cout<<"\nBlood Group : "<<p->blood;
196 cout<<"\nMobile Number : "<<p->ID;
197 cout<<"\n**********************************\n";
198 p=p->next;
199 }
200 cout<<"\n";
201 }
202
203
204 void departmentmenu (linkedqueue * q)
205 {
206 int choice = 0, success;
207 patient p;
208 while (choice != 5)
209 {
210 system("cls");
211 cout<<"\n\n\tWelcome To Department : " << q->departmentname;
212 cout<<"\n\t\t[1] Add normal patient\n";
213 cout<<"\t\t[2] Add critically ill patient\n";
214 cout<<"\t\t[3] Take patient to Doctor\n";
215 cout<<"\t\t[4] Display list\n";
216 cout<<"\t\t[5] Change department or exit\n";
217 cout<<"\n\tPlease enter your choice : ";
218 choice=readnumber();
219
220 switch (choice)
221 {
222 case 1: q->insertatend();
223 cout << "\n\tPress any key";
224 getch();
225 break;
226
227 case 2: q->insertatbeg();
228 cout << "\n\tPress any key";
229 getch();
230 break;
231
232 case 3: q->getpatientout();
233 cout<<"\n\tPress any key";
234 getch();
235 break;
236
237 case 4: system("cls");
238 q->listofpatients();
239 cout<<"\n\tPress any key";
240 getch();
241 break;
242 }
243 }
244 }
245
246 int main ()
247 {
248 int i, choice = 0;
249 linkedqueue departments[4];
250 system("COLOR 5F");
251
252 while(choice!=5)
253 {
254 strcpy(departments[0].departmentname,"General Clinic\n");
255 strcpy(departments[1].departmentname,"Heart Clinic\n");
256 strcpy(departments[2].departmentname,"Lung Clinic\n");
257 strcpy(departments[3].departmentname,"Plastic Surgery\n");
258 system("cls");
259 cout<<"\n\t>>>>>>>>>>>>>>>>>>>>>>>>>>";
260 cout<<"\n\tHOSPITAL MANAGEMENT SYSTEM\t";
261 cout<<"\n\t<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n";
262 for (i = 0; i < 4; i++)
263 {
264 cout<<"\t"<<(i+1)<<": "<<departments[i].departmentname;
265 }
266 cout<<"\t5: Exit";
267 cout<<"\n\n\tPlease enter your choice : ";
268 choice=readnumber();
269 if(choice>=1 && choice<=4)
270 {
271 departmentmenu(&departments[choice-1]);
272 }
273
274 }
275 if(choice==5)
276 cout<<"\n\t\tThanks To avianshpotnuru \n";
277 cout<<"\t\tBrought To You By code-projects.org";
278 exit(0); //system end cp
279 }